using System;

namespace csammisrun.OscarLib.Utility
{
	/// <summary>
	/// Encapsulates a generic SSI item
	/// </summary>
	internal class SSIItem
	{
		/// <summary>
		/// The name of this item
		/// </summary>
		public string Name;
		/// <summary>
		/// The item's Group ID
		/// </summary>
		public ushort GroupID;
		/// <summary>
		/// The item's Item ID
		/// </summary>
		public ushort ItemID;
		/// <summary>
		/// The type of the item
		/// </summary>
		public ushort ItemType;
		/// <summary>
		/// The TLVs included with this SSI item
		/// </summary>
		public TLV[] Tlvs = null;
	}

	/// <summary>
	/// Encapsulates an SSI item representing a single contact
	/// </summary>
	class BuddyItem : SSIItem
	{
		/// <summary>
		/// The display name of the contact
		/// </summary>
		/// <remarks>This is initialized to be the same as the parent <see cref="SSIItem"/>'s name</remarks>
		public string DisplayName = "";
		/// <summary>
		/// The locally assigned email address of this contact
		/// </summary>
		public string Email = "";
		/// <summary>
		/// The contact's SMS information
		/// </summary>
		public string SMS = "";
		/// <summary>
		/// A locally assigned comment about this contact
		/// </summary>
		public string Comment = "";
		/// <summary>
		/// Two bytes representing the different possible alert styles
		/// </summary>
		public ushort Alerts = 0;
		/// <summary>
		/// A sound file to play when this contact signs on
		/// </summary>
		public string SoundFile = "";
		/// <summary>
		/// Indicates whether the local client is awaiting authorization by the remote contact
		/// </summary>
		public bool AwaitingAuthorization = false;

		/// <summary>
		/// Creates a new BuddyItem
		/// </summary>
		/// <param name="si">The <see cref="SSIItem"/> upon which this BuddyItem is based</param>
		public BuddyItem(SSIItem si)
		{
			GroupID = si.GroupID;
			ItemID = si.ItemID;
			ItemType = si.ItemType;
			Name = DisplayName = si.Name;
		}
	}

	/// <summary>
	/// Encapsulates an SSI item representing a group of contacts
	/// </summary>
	class GroupItem : SSIItem
	{
		/// <summary>
		/// A list of the child item IDs contained by this group
		/// </summary>
		/// <remarks>
		/// If this group is the Master Group (that is, its group ID is 0x0000), the item IDs
		/// in this array are other GroupItems. Otherwise, the item IDs refer to BuddyItem IDs.
		/// </remarks>
		public ushort[] Children = null;

		/// <summary>
		/// Creates a new GroupItem
		/// </summary>
		/// <param name="si">The <see cref="SSIItem"/> upon which this GroupItem is based</param>
		public GroupItem(SSIItem si)
		{
			GroupID = si.GroupID;
			ItemID = si.ItemID;
			ItemType = si.ItemType;
			Name = si.Name;
		}
	}

	/// <summary>
	/// Encapsulates an SSI item representing an "Allow" list entry
	/// </summary>
	class PermitItem : SSIItem
	{
		/// <summary>
		/// Creates a new PermitItem
		/// </summary>
		/// <param name="si">The <see cref="SSIItem"/> upon which this PermitItem is based</param>
		public PermitItem(SSIItem si)
		{
			GroupID = si.GroupID;
			ItemID = si.ItemID;
			ItemType = si.ItemType;
			Name = si.Name;
		}
	}

	/// <summary>
	/// Encapsulates an SSI item representing an "Block" list entry
	/// </summary>
	class DenyItem : SSIItem
	{
		/// <summary>
		/// Creates a new DenyItem
		/// </summary>
		/// <param name="si">The <see cref="SSIItem"/> upon which this DenyItem is based</param>
		public DenyItem(SSIItem si)
		{
			GroupID = si.GroupID;
			ItemID = si.ItemID;
			ItemType = si.ItemType;
			Name = si.Name;
		}
	}
}
